﻿using System;
using System.Web.UI;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

namespace RibbonCustomization.RibbonPages
{
    public class DemoPage7
        : WebPartPage
    {
        public const string TabWithControlsAndCommandsID = "Ribbon.TabWithControlsAndCommands";

        protected override void OnPreRender(EventArgs e)
        {
            SPRibbon ribbon = SPRibbon.GetCurrent(Page);
            if (ribbon != null)
            {
                ribbon.MakeTabAvailable(TabWithControlsAndCommandsID);
                Page.ClientScript.RegisterStartupScript(
                    typeof(DemoPage7),
                    "DemoPage7",
                    ScriptLink.BuildDelayedExecutionScript(
                        "SamplePageComponent.js",
                        "RibbonCustomization.SamplePageComponent.init") + ";", 
                    true);

                ScriptLink.RegisterScriptAfterUI(Page, "RibbonCustomization/SamplePageComponent.js", false, true);
            }
            base.OnPreRender(e);
        }
    }
}
